package com.ouc.openplatform.ouc.authManage.service.impl;

import java.util.List;

import com.ouc.openplatform.ouc.authManage.dao.NJ_DepartmentStructureDAO;
import com.ouc.openplatform.ouc.authManage.model.NJ_DepartmentStructure;
import com.ouc.openplatform.ouc.authManage.service.NJ_DepartmentStructureService;


public class NJ_DepartmentStructureServiceImpl implements NJ_DepartmentStructureService {
	private NJ_DepartmentStructureDAO departmentStructureDao;

	public NJ_DepartmentStructureDAO getDepartmentStructureDao() {
		return departmentStructureDao;
	}

	public void setDepartmentStructureDao(NJ_DepartmentStructureDAO departmentStructureDao) {
		this.departmentStructureDao = departmentStructureDao;
	}

	// 1.保存部门信息-----sxl
	@Override
	public int saveDepartmentStructure(NJ_DepartmentStructure departmentStructure) {
		int flag = departmentStructureDao.insert(departmentStructure);
		return flag;
	}
	// 2.根据部门id删除部门信息---------sxl
	@Override
	public int deleteDepartmentStructure(int id) {
		int flag = departmentStructureDao.deleteByPrimaryKey(id);
		return flag;
	}
	// 3.修改部门信息-----sxl
	@Override
	public int updateDepartmentStructure(NJ_DepartmentStructure departmentStructure) {
		int flag = departmentStructureDao.updateByPrimaryKeySelective(departmentStructure);
		return flag;
	}

	// 4.根据父级id查询所有的部门信息------sxl
	@Override
	public List<NJ_DepartmentStructure> getAllDepStructureBypid(int id) {
		return departmentStructureDao.getAllDepStructureBypid(id);
	}

	// 5.根据部门名称,部门编码和父级id判断部门名是否存在-----sxl
	@Override
	public int IsOkDepartment(String departmentName, String departmentCode, int pid) {
		return departmentStructureDao.IsOkDepartment(departmentName, departmentCode, pid)==null?0:1;
	}
	
	
	
	// 根据父级id查询直接子id的个数------sxl
	@Override
	public int getDepStructureCountBypid(int id) {
		return departmentStructureDao.getDepStructureCountBypid(id);
	}

	// 获取所有部门信息
	@Override
	public List<NJ_DepartmentStructure> getAllDepartmentStructure(NJ_DepartmentStructure departmentStructure) {
		return departmentStructureDao.select(departmentStructure);
	}

}
